import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score

# 1. 读取数据集
data = pd.read_csv('B_FQT.csv')

# 2. 准备数据
X = data.drop('Q1-重力异常值梯度', axis=1)  # 替换 'target_variable' 为您的目标变量列名
y = data['Q1-重力异常值梯度']

# 3. 拆分数据集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 4. 创建SVM模型
svm_model = SVC(C=1.0, kernel='rbf')  # 根据需要调整参数

# 5. 拟合模型
svm_model.fit(X_train, y_train)

# 6. 进行预测
y_pred = svm_model.predict(X_test)

# 7. 评估模型
accuracy = accuracy_score(y_test, y_pred)
print("准确度：", accuracy)
